var baseUrl = 'https://test.hsysns.com';

getCurrentFlag();
var isMobileFlag = isMobile();
var isPcFlag = isPC();
if ( isMobileFlag ){
    //alert('m');
}
if ( isPcFlag ){
    //alert('PC');
}


// 判断是否为移动设备
function isMobile() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)){
        return true;
    }
}

// 判断是否为 PC 设备
function isPC() {
    if (!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)){
        return true;
    }
}

if (isMobile()) {
    window.location.href = "http://m.example.com";
}

// // 点击“回到电脑版网站”时，跳转到电脑版网站
// $("#returnToPC").click(function(){
//     if (isPC()) {
//         window.location.href = "http://www.example.com";
//     }
// });

function getCurrentFlag(){
    let currentUrl = window.location.href;
    let pos1 = currentUrl.lastIndexOf("://");
    let pos2 = currentUrl.indexOf(".");
    if ( pos2 !== -1 ){
        let res = currentUrl.slice(pos1 + 1, pos2);
        //console.log(res);
        //$(`.${res}`).addClass('active');
    }
}